package agile.tools;

import net.sf.json.JSON;
import net.sf.json.JSONSerializer;
import net.sf.json.JsonConfig;
import flexjson.JSONDeserializer;

class TestSaver1 {
	public static void main(String[] args) {
		TestSaver1 d = new TestSaver1();
		try {
			d.tryjsonlib();
		} catch (Throwable th) {
			th.printStackTrace();
		}
		System.out.println("**************************************************");
		d.tryflexjson();
	}

	public void tryflexjson() {
		Person p = new Person();
		flexjson.JSONSerializer serializer = new flexjson.JSONSerializer();
		serializer.prettyPrint(true);
		String json = serializer.serialize(p);
		System.out.println(json);
		json = json.replace("Ayan", "Ankit");
		json = json.replace("OH", "FL");
		System.out.println(json);
		Person p1 = (Person) new flexjson.JSONDeserializer().deserialize(json);
		System.out.println(p);
		System.out.println(p1);
	}

	public void tryjsonlib() {
		Person p = new Person();
		JSON json = JSONSerializer.toJSON(p);
		System.out.println(p);
		System.out.println(json);
		System.out.println(json.toString(2));
		JsonConfig config = new JsonConfig();
		config.setRootClass(Person.class);
		Person p1 = (Person) JSONSerializer.toJava(json, config);
		System.out.println(p1);
		Object o2 = new JSONDeserializer().deserialize(json.toString());
		System.out.println(o2);
	}
}